{#<!DOCTYPE html>#}
{#<html>#}
{#<head>#}
{#<meta charset="utf-8">#}
{#<title>Boards</title>#}
{#</head>#}
{#<body>#}
{#<h1>Boards</h1>#}
{#<table border="1">#}
{#<thead>#}
{#<tr>#}
{#<th>Board</th>#}
{#<th>Posts</th>#}
{#<th>Topics</th>#}
{#<th>Last Post</th>#}
{#</tr>#}
{#</thead>#}
{#<tbody>#}
{#{% for board in boards %}#}
{#<tr>#}
{#<td>#}
{#<a href="{% url 'board_topics' board.pk %}">{{ board.name }}</a>#}
{#<small style="color: #888">{{ board.description}}</small>#}
{#</td>#}
{#<td>0</td>#}
{#<td>0</td>#}
{#<td></td>#}
{#</tr>#}
{#{% endfor %}#}
{#</tbody>#}
{#</table>#}
{#</body>#}
{#</html>#}

{% extends 'base.html' %}

{% block breadcrumb %}
    <li class="breadcrumb-item active">Boards</li>
{% endblock %}

{% block content %}
    <table class="table" >
        <thead class="thead-inverse">
            <tr>
                <th>Board</th>
                <th>Posts</th>
                <th>Topics</th>
                <th>Last Post</th>
            </tr>
        </thead>
        <tbody>
            {% for board in boards %}
                <tr>
                    <td>
                        <a href="{% url 'board_topics' board.pk %}">{{ board.name }}</a>
                        <small clss="text-muted d-block">{{ board.description}}</small>
                    </td>
                    <td class="align-middle">{{ board.get_posts_count }}</td>
                    <td class="align-middle">{{ board.topics.count }}</td>
                    <td class="align-middle">
                        {% with post=board.get_last_post %}
                            {% if post %}
                            <small>
                            <a href="{% url 'topic_posts'  board.pk post.topic.pk %}">
                                By {{ post.created_by.username }} at{{ post.created_at }}
                            </a>
                            </small>
                            {% else %}
                                <small class="text-muted">
                                <em>No posts yet</em>
                                </small>
                            {% endif %}
                        {% endwith %}
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
{% endblock %}